#######################################################################################################
##### Code for replicating all regressions presented in main text and supplementary materials of ######
# "How Economic, Humanitarian, and Religious Concerns Shape European Attitudes toward Asylum-Seekers" #
################################## (Bansak, Hainmueller, Hangartner) ##################################
#######################################################################################################


library(plyr)
library(ggplot2)
library(xtable)
library(lmtest)
library(sandwich)
library(texreg)
library(grid)
library(gridExtra)


# Read in conjoint (profile obs) and respondent (respondent obs) data ----

svyx <- read.csv("conjoint_data_final.csv")
svyz <- read.csv("respondent_data_final.csv")


# Read in function for clustered variance estimator -----------------------

source("vcovCluster.R")


# Import respondent characteristics into conjoint dataframe ---------------

svyx$Female <- rep(svyz$Female, each = 10)
svyx$Female[svyx$Female == 0] <- "Male"
svyx$Female[svyx$Female == 1] <- "Female"

svyx$AgeGroup <- rep(svyz$AgeGroup, each = 10)

svyx$OldAge <- rep(svyz$OldAge, each = 10)
svyx$OldAge[svyx$OldAge == 0] <- "Young"
svyx$OldAge[svyx$OldAge == 1] <- "Old"

svyx$Income <- rep(svyz$IncomeDecile, each = 10)
svyx$HighIncome[svyx$Income <= 5] <- "Below Median Income"
svyx$HighIncome[svyx$Income > 5] <- "Above Median Income"

svyx$HighEducation <- rep(svyz$HighEducation, each = 10)

svyx$EISCED <- rep(svyz$EISCED, each = 10)

svyx$L <- rep(svyz$L, each = 10)
svyx$C <- rep(svyz$C, each = 10)
svyx$R <- rep(svyz$R, each = 10)

svyx$LeftRight <- NA
svyx$LeftRight[svyx$L == 1] <- "Left"
svyx$LeftRight[svyx$C == 1] <- "Center"
svyx$LeftRight[svyx$R == 1] <- "Right"

svyx$Ideo5 <- rep(svyz$Ideo5, each = 10)
svyx$Ideo5 <- as.character(svyx$Ideo5)
svyx$Ideo5[svyx$Ideo5 == "1. Far Left"] <- "Far Left"
svyx$Ideo5[svyx$Ideo5 == "2. Left"] <- "Left"
svyx$Ideo5[svyx$Ideo5 == "3. Center"] <- "Center"
svyx$Ideo5[svyx$Ideo5 == "4. Right"] <- "Right"
svyx$Ideo5[svyx$Ideo5 == "5. Far Right"] <- "Far Right"
svyx$Ideo5 <- as.factor(svyx$Ideo5)

svyx$EmpStatus <- rep(svyz$EmpStatus, each=10)
svyx$EmpStatus <- revalue(svyx$EmpStatus, c("1. Paid employee"="Paid employee","2. Self-employed"="Self-employed","3. Student"="Student",
                                            "4. Unemployed, searching"="Unemployed, searching","5. Unemployed, not searching"="Unemployed, not searching",
                                            "6. Chronic illness or permanent disability"="Chronic illness or permanent disability",
                                            "7. Retired"="Retired","8. Working at home"="Working at home"))

svyx$Empathy <- rep(svyz$Empathy, each = 10)
svyx$Empathy5 <- cut(svyx$Empathy,breaks=c(quantile(svyx$Empathy,0)-1,quantile(svyx$Empathy,0.2),quantile(svyx$Empathy,0.4),quantile(svyx$Empathy,0.6),quantile(svyx$Empathy,0.8),quantile(svyx$Empathy,1)))
svyx$Empathy5 <- revalue(svyx$Empathy5, c("(-13,0]"="Empathy Quintile 1", "(0,2]"="Empathy Quintile 2","(2,4]"="Empathy Quintile 3","(4,6]"="Empathy Quintile 4","(6,12]"="Empathy Quintile 5"))

svyx$EmpathyA <- rep(svyz$Empathy1, each = 10)
svyx$EmpathyA5 <- cut(svyx$EmpathyA,breaks=c(quantile(svyx$EmpathyA,0)-1,quantile(svyx$EmpathyA,0.2),quantile(svyx$EmpathyA,0.4),quantile(svyx$EmpathyA,0.6),quantile(svyx$EmpathyA,0.8),quantile(svyx$EmpathyA,1)))
svyx$EmpathyA5 <- revalue(svyx$EmpathyA5, c("(-7,0]"="Empathy Quintile 1", "(0,1]"="Empathy Quintile 2","(1,3]"="Empathy Quintile 3","(3,4]"="Empathy Quintile 4","(4,6]"="Empathy Quintile 5"))

svyx$EmpathyB <- rep(svyz$Empathy2, each = 10)
svyx$EmpathyB5 <- cut(svyx$EmpathyB,breaks=c(quantile(svyx$EmpathyB,0)-1,quantile(svyx$EmpathyB,0.2),quantile(svyx$EmpathyB,0.4),quantile(svyx$EmpathyB,0.6),quantile(svyx$EmpathyB,0.8),quantile(svyx$EmpathyB,1)))
svyx$EmpathyB5 <- revalue(svyx$EmpathyB5, c("(-7,0]"="Empathy Quintile 1", "(0,1]"="Empathy Quintile 2","(1,2]"="Empathy Quintile 3","(2,3]"="Empathy Quintile 4","(3,6]"="Empathy Quintile 5"))

svyx$HomeBorn <- rep(svyz$HomeBorn, each = 10)

svyx$duration <- rep(svyz$duration, each = 10)

svyx$lrgen <- rep(svyz$lrgen, each = 10)


# Final preparations for data analysis ------------------------------------

#ensure conjoint attributes are factor variables
svyx$cconsist <- factor(svyx$cconsist)
svyx$cgender <- factor(svyx$cgender)
svyx$corigin <- factor(svyx$corigin)
svyx$cage <- factor(svyx$cage)
svyx$cjob <- factor(svyx$cjob)
svyx$cvulner <- factor(svyx$cvulner)
svyx$creason <- factor(svyx$creason)
svyx$creligion <- factor(svyx$creligion)
svyx$clang <- factor(svyx$clang)

#remove the respondents with missing conjoint data
svyp <- subset(svyx,svyx$cconsist != "<NA>")

#top-code weights
svyp$weight[svyp$weight > 6] <- 6

#omit observations with NA weights 
svypw <- subset(svyp,!is.na(svyp$weight))



# Pooled regressions (including Fig. 2 model) -----------------------------

#weighted, forced choice DV (main model used for Fig. 2 of main text)
basemodweiFC <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw, weights = weight)
coeftest(basemodweiFC, vcov = vcovCluster(basemodweiFC, factor(svypw$respid)))
#unweighted, forced choice DV
basemodunwFC <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svyp)
coeftest(basemodunwFC, vcov = vcovCluster(basemodunwFC, factor(svyp$respid)))

#weighted, binary rating DV
basemodweiBR <- lm(ratebin ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw, weights = weight)
coeftest(basemodweiBR, vcov = vcovCluster(basemodweiBR, factor(svypw$respid)))
#unweighted, binary rating DV
basemodunwBR <- lm(ratebin ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svyp)
coeftest(basemodunwBR, vcov = vcovCluster(basemodunwBR, factor(svyp$respid)))

#weighted, scaled rating DV
basemodweiSR <- lm(ratescaled ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw, weights = weight)
coeftest(basemodweiSR, vcov = vcovCluster(basemodweiSR, factor(svypw$respid)))
#unweighted, scaled rating DV
basemodunwSR <- lm(ratescaled ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svyp)
coeftest(basemodunwSR, vcov = vcovCluster(basemodunwSR, factor(svyp$respid)))


# Primary subset regressions (Fig. 3 models use forced choice DV) ---------

#Young vs. old
svypw.young <- subset(svypw,svypw$OldAge == "Young")
svypw.old <- subset(svypw,svypw$OldAge == "Old")

mod.youngFC <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.young, weights = weight)
coeftest(mod.youngFC, vcov = vcovCluster(mod.youngFC, factor(svypw.young$respid)))
mod.oldFC <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.old, weights = weight)
coeftest(mod.oldFC, vcov = vcovCluster(mod.oldFC, factor(svypw.old$respid)))

mod.youngBR <- lm(ratebin ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.young, weights = weight)
coeftest(mod.youngBR, vcov = vcovCluster(mod.youngBR, factor(svypw.young$respid)))
mod.oldBR <- lm(ratebin ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.old, weights = weight)
coeftest(mod.oldBR, vcov = vcovCluster(mod.oldBR, factor(svypw.old$respid)))

mod.youngSR <- lm(ratescaled ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.young, weights = weight)
coeftest(mod.youngSR, vcov = vcovCluster(mod.youngSR, factor(svypw.young$respid)))
mod.oldSR <- lm(ratescaled ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.old, weights = weight)
coeftest(mod.oldSR, vcov = vcovCluster(mod.oldSR, factor(svypw.old$respid)))


#Below and above median income
svypw.poor <- subset(svypw,svypw$HighIncome == "Below Median Income")
svypw.rich <- subset(svypw,svypw$HighIncome == "Above Median Income")

mod.poorFC <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.poor, weights = weight)
coeftest(mod.poorFC, vcov = vcovCluster(mod.poorFC, factor(svypw.poor$respid)))
mod.richFC <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.rich, weights = weight)
coeftest(mod.richFC, vcov = vcovCluster(mod.richFC, factor(svypw.rich$respid)))

mod.poorBR <- lm(ratebin ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.poor, weights = weight)
coeftest(mod.poorBR, vcov = vcovCluster(mod.poorBR, factor(svypw.poor$respid)))
mod.richBR <- lm(ratebin ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.rich, weights = weight)
coeftest(mod.richBR, vcov = vcovCluster(mod.richBR, factor(svypw.rich$respid)))

mod.poorSR <- lm(ratescaled ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.poor, weights = weight)
coeftest(mod.poorSR, vcov = vcovCluster(mod.poorSR, factor(svypw.poor$respid)))
mod.richSR <- lm(ratescaled ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.rich, weights = weight)
coeftest(mod.richSR, vcov = vcovCluster(mod.richSR, factor(svypw.rich$respid)))


#Low vs. high education
svypw.lowed <- subset(svypw,svypw$HighEducation == "Low Education")
svypw.highed <- subset(svypw,svypw$HighEducation == "High Education")

mod.lowedFC <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.lowed, weights = weight)
coeftest(mod.lowedFC, vcov = vcovCluster(mod.lowedFC, factor(svypw.lowed$respid)))
mod.highedFC <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.highed, weights = weight)
coeftest(mod.highedFC, vcov = vcovCluster(mod.highedFC, factor(svypw.highed$respid)))

mod.lowedBR <- lm(ratebin ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.lowed, weights = weight)
coeftest(mod.lowedBR, vcov = vcovCluster(mod.lowedBR, factor(svypw.lowed$respid)))
mod.highedBR <- lm(ratebin ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.highed, weights = weight)
coeftest(mod.highedBR, vcov = vcovCluster(mod.highedBR, factor(svypw.highed$respid)))

mod.lowedSR <- lm(ratescaled ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.lowed, weights = weight)
coeftest(mod.lowedSR, vcov = vcovCluster(mod.lowedSR, factor(svypw.lowed$respid)))
mod.highedSR <- lm(ratescaled ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.highed, weights = weight)
coeftest(mod.highedSR, vcov = vcovCluster(mod.highedSR, factor(svypw.highed$respid)))


#Left vs. right political ideology
svypw.left <- subset(svypw,svypw$LeftRight == "Left")
svypw.right <- subset(svypw,svypw$LeftRight == "Right")

mod.leftFC <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.left, weights = weight)
coeftest(mod.leftFC, vcov = vcovCluster(mod.leftFC, factor(svypw.left$respid)))
mod.rightFC <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.right, weights = weight)
coeftest(mod.rightFC, vcov = vcovCluster(mod.rightFC, factor(svypw.right$respid)))

mod.leftBR <- lm(ratebin ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.left, weights = weight)
coeftest(mod.leftBR, vcov = vcovCluster(mod.leftBR, factor(svypw.left$respid)))
mod.rightBR <- lm(ratebin ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.right, weights = weight)
coeftest(mod.rightBR, vcov = vcovCluster(mod.rightBR, factor(svypw.right$respid)))

mod.leftSR <- lm(ratescaled ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.left, weights = weight)
coeftest(mod.leftSR, vcov = vcovCluster(mod.leftSR, factor(svypw.left$respid)))
mod.rightSR <- lm(ratescaled ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.right, weights = weight)
coeftest(mod.rightSR, vcov = vcovCluster(mod.rightSR, factor(svypw.right$respid)))


# Other subset regressions for Supplementary Materials --------------------

#Across finer grained ideological subsets (5-point political ideology)
svypw.ideo5.farleft <- subset(svypw,svypw$Ideo5 == "Far Left")
svypw.ideo5.left <- subset(svypw,svypw$Ideo5 == "Left")
svypw.ideo5.center <- subset(svypw,svypw$Ideo5 == "Center")
svypw.ideo5.right <- subset(svypw,svypw$Ideo5 == "Right")
svypw.ideo5.farright <- subset(svypw,svypw$Ideo5 == "Far Right")

mod.ideo5.farleft <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.ideo5.farleft, weights = weight)
coeftest(mod.ideo5.farleft, vcov = vcovCluster(mod.ideo5.farleft, factor(svypw.ideo5.farleft$respid)))
mod.ideo5.left <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.ideo5.left, weights = weight)
coeftest(mod.ideo5.left, vcov = vcovCluster(mod.ideo5.left, factor(svypw.ideo5.left$respid)))
mod.ideo5.center <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.ideo5.center, weights = weight)
coeftest(mod.ideo5.center, vcov = vcovCluster(mod.ideo5.center, factor(svypw.ideo5.center$respid)))
mod.ideo5.right <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.ideo5.right, weights = weight)
coeftest(mod.ideo5.right, vcov = vcovCluster(mod.ideo5.right, factor(svypw.ideo5.right$respid)))
mod.ideo5.farright <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.ideo5.farright, weights = weight)
coeftest(mod.ideo5.farright, vcov = vcovCluster(mod.ideo5.farright, factor(svypw.ideo5.farright$respid)))


#Across finer grained age subsets
svypw.agegroup.29under <- subset(svypw,svypw$AgeGroup == "29 and under")
svypw.agegroup.3039 <- subset(svypw,svypw$AgeGroup == "30-39")
svypw.agegroup.4049 <- subset(svypw,svypw$AgeGroup == "40-49")
svypw.agegroup.5059 <- subset(svypw,svypw$AgeGroup == "50-59")
svypw.agegroup.60up <- subset(svypw,svypw$AgeGroup == "60 and over")

mod.agegroup.29under <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.agegroup.29under, weights = weight)
coeftest(mod.agegroup.29under, vcov = vcovCluster(mod.agegroup.29under, factor(svypw.agegroup.29under$respid)))
mod.agegroup.3039 <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.agegroup.3039, weights = weight)
coeftest(mod.agegroup.3039, vcov = vcovCluster(mod.agegroup.3039, factor(svypw.agegroup.3039$respid)))
mod.agegroup.4049 <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.agegroup.4049, weights = weight)
coeftest(mod.agegroup.4049, vcov = vcovCluster(mod.agegroup.4049, factor(svypw.agegroup.4049$respid)))
mod.agegroup.5059 <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.agegroup.5059, weights = weight)
coeftest(mod.agegroup.5059, vcov = vcovCluster(mod.agegroup.5059, factor(svypw.agegroup.5059$respid)))
mod.agegroup.60up <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.agegroup.60up, weights = weight)
coeftest(mod.agegroup.60up, vcov = vcovCluster(mod.agegroup.60up, factor(svypw.agegroup.60up$respid)))


#Across finer grained education subsets
svypw.EISCED1 <- subset(svypw,svypw$EISCED == 1)
svypw.EISCED2 <- subset(svypw,svypw$EISCED == 2)
svypw.EISCED3 <- subset(svypw,svypw$EISCED == 3)
svypw.EISCED4 <- subset(svypw,svypw$EISCED == 4)
svypw.EISCED5 <- subset(svypw,svypw$EISCED == 5)
svypw.EISCED6 <- subset(svypw,svypw$EISCED == 6)
svypw.EISCED7 <- subset(svypw,svypw$EISCED == 7)

mod.EISCED1 <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.EISCED1, weights = weight)
coeftest(mod.EISCED1, vcov = vcovCluster(mod.EISCED1, factor(svypw.EISCED1$respid)))
mod.EISCED2 <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.EISCED2, weights = weight)
coeftest(mod.EISCED2, vcov = vcovCluster(mod.EISCED2, factor(svypw.EISCED2$respid)))
mod.EISCED3 <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.EISCED3, weights = weight)
coeftest(mod.EISCED3, vcov = vcovCluster(mod.EISCED3, factor(svypw.EISCED3$respid)))
mod.EISCED4 <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.EISCED4, weights = weight)
coeftest(mod.EISCED4, vcov = vcovCluster(mod.EISCED4, factor(svypw.EISCED4$respid)))
mod.EISCED5 <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.EISCED5, weights = weight)
coeftest(mod.EISCED5, vcov = vcovCluster(mod.EISCED5, factor(svypw.EISCED5$respid)))
mod.EISCED6 <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.EISCED6, weights = weight)
coeftest(mod.EISCED6, vcov = vcovCluster(mod.EISCED6, factor(svypw.EISCED6$respid)))
mod.EISCED7 <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.EISCED7, weights = weight)
coeftest(mod.EISCED7, vcov = vcovCluster(mod.EISCED7, factor(svypw.EISCED7$respid)))


#Across finer grained income subsets (quintiles)
svypw.income.1 <- subset(svypw,svypw$Income == 1 | svypw$Income == 2)
svypw.income.2 <- subset(svypw,svypw$Income == 3 | svypw$Income == 4)
svypw.income.3 <- subset(svypw,svypw$Income == 5 | svypw$Income == 6)
svypw.income.4 <- subset(svypw,svypw$Income == 7 | svypw$Income == 8)
svypw.income.5 <- subset(svypw,svypw$Income == 9 | svypw$Income == 10)

mod.income.1 <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.income.1, weights = weight)
coeftest(mod.income.1, vcov = vcovCluster(mod.income.1, factor(svypw.income.1$respid)))
mod.income.2 <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.income.2, weights = weight)
coeftest(mod.income.2, vcov = vcovCluster(mod.income.2, factor(svypw.income.2$respid)))
mod.income.3 <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.income.3, weights = weight)
coeftest(mod.income.3, vcov = vcovCluster(mod.income.3, factor(svypw.income.3$respid)))
mod.income.4 <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.income.4, weights = weight)
coeftest(mod.income.4, vcov = vcovCluster(mod.income.4, factor(svypw.income.4$respid)))
mod.income.5 <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.income.5, weights = weight)
coeftest(mod.income.5, vcov = vcovCluster(mod.income.5, factor(svypw.income.5$respid)))


#Across gender subsets
svypw.male <- subset(svypw,svypw$Female == "Male")
svypw.female <- subset(svypw,svypw$Female == "Female")

mod.male <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.male, weights = weight)
coeftest(mod.male, vcov = vcovCluster(mod.male, factor(svypw.male$respid)))
mod.female <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.female, weights = weight)
coeftest(mod.female, vcov = vcovCluster(mod.female, factor(svypw.female$respid)))


#Across employment status subsets
svypw.employ.1 <- subset(svypw,svypw$EmpStatus == "Paid employee")
svypw.employ.2 <- subset(svypw,svypw$EmpStatus == "Self-employed")
svypw.employ.3 <- subset(svypw,svypw$EmpStatus == "Student")
svypw.employ.4 <- subset(svypw,svypw$EmpStatus == "Unemployed, searching")
svypw.employ.5 <- subset(svypw,svypw$EmpStatus == "Unemployed, not searching")
svypw.employ.6 <- subset(svypw,svypw$EmpStatus == "Chronic illness or permanent disability")
svypw.employ.7 <- subset(svypw,svypw$EmpStatus == "Retired")
svypw.employ.8 <- subset(svypw,svypw$EmpStatus == "Working at home")

mod.employ.1 <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.employ.1, weights = weight)
coeftest(mod.employ.1, vcov = vcovCluster(mod.employ.1, factor(svypw.employ.1$respid)))
mod.employ.2 <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.employ.2, weights = weight)
coeftest(mod.employ.2, vcov = vcovCluster(mod.employ.2, factor(svypw.employ.2$respid)))
mod.employ.3 <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.employ.3, weights = weight)
coeftest(mod.employ.3, vcov = vcovCluster(mod.employ.3, factor(svypw.employ.3$respid)))
mod.employ.4 <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.employ.4, weights = weight)
coeftest(mod.employ.4, vcov = vcovCluster(mod.employ.4, factor(svypw.employ.4$respid)))
mod.employ.5 <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.employ.5, weights = weight)
coeftest(mod.employ.5, vcov = vcovCluster(mod.employ.5, factor(svypw.employ.5$respid)))
mod.employ.6 <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.employ.6, weights = weight)
coeftest(mod.employ.6, vcov = vcovCluster(mod.employ.6, factor(svypw.employ.6$respid)))
mod.employ.7 <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.employ.7, weights = weight)
coeftest(mod.employ.7, vcov = vcovCluster(mod.employ.7, factor(svypw.employ.7$respid)))
mod.employ.8 <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.employ.8, weights = weight)
coeftest(mod.employ.8, vcov = vcovCluster(mod.employ.8, factor(svypw.employ.8$respid)))


#Across empathy (combined empathic concern and perspective taking constructs) subsets
svypw.empathy.1 <- subset(svypw,svypw$Empathy5 == "Empathy Quintile 1")
svypw.empathy.2 <- subset(svypw,svypw$Empathy5 == "Empathy Quintile 2")
svypw.empathy.3 <- subset(svypw,svypw$Empathy5 == "Empathy Quintile 3")
svypw.empathy.4 <- subset(svypw,svypw$Empathy5 == "Empathy Quintile 4")
svypw.empathy.5 <- subset(svypw,svypw$Empathy5 == "Empathy Quintile 5")

mod.empathy.1 <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.empathy.1, weights = weight)
coeftest(mod.empathy.1, vcov = vcovCluster(mod.empathy.1, factor(svypw.empathy.1$respid)))
mod.empathy.2 <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.empathy.2, weights = weight)
coeftest(mod.empathy.2, vcov = vcovCluster(mod.empathy.2, factor(svypw.empathy.2$respid)))
mod.empathy.3 <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.empathy.3, weights = weight)
coeftest(mod.empathy.3, vcov = vcovCluster(mod.empathy.3, factor(svypw.empathy.3$respid)))
mod.empathy.4 <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.empathy.4, weights = weight)
coeftest(mod.empathy.4, vcov = vcovCluster(mod.empathy.4, factor(svypw.empathy.4$respid)))
mod.empathy.5 <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.empathy.5, weights = weight)
coeftest(mod.empathy.5, vcov = vcovCluster(mod.empathy.5, factor(svypw.empathy.5$respid)))


#Across empathy (empathic concern construct) subsets
svypw.empathyA.1 <- subset(svypw,svypw$EmpathyA5 == "Empathy Quintile 1")
svypw.empathyA.2 <- subset(svypw,svypw$EmpathyA5 == "Empathy Quintile 2")
svypw.empathyA.3 <- subset(svypw,svypw$EmpathyA5 == "Empathy Quintile 3")
svypw.empathyA.4 <- subset(svypw,svypw$EmpathyA5 == "Empathy Quintile 4")
svypw.empathyA.5 <- subset(svypw,svypw$EmpathyA5 == "Empathy Quintile 5")

mod.empathyA.1 <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.empathyA.1, weights = weight)
coeftest(mod.empathyA.1, vcov = vcovCluster(mod.empathyA.1, factor(svypw.empathyA.1$respid)))
mod.empathyA.2 <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.empathyA.2, weights = weight)
coeftest(mod.empathyA.2, vcov = vcovCluster(mod.empathyA.2, factor(svypw.empathyA.2$respid)))
mod.empathyA.3 <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.empathyA.3, weights = weight)
coeftest(mod.empathyA.3, vcov = vcovCluster(mod.empathyA.3, factor(svypw.empathyA.3$respid)))
mod.empathyA.4 <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.empathyA.4, weights = weight)
coeftest(mod.empathyA.4, vcov = vcovCluster(mod.empathyA.4, factor(svypw.empathyA.4$respid)))
mod.empathyA.5 <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.empathyA.5, weights = weight)
coeftest(mod.empathyA.5, vcov = vcovCluster(mod.empathyA.5, factor(svypw.empathyA.5$respid)))


#Across empathy (perspective taking construct) subsets
svypw.empathyB.1 <- subset(svypw,svypw$EmpathyB5 == "Empathy Quintile 1")
svypw.empathyB.2 <- subset(svypw,svypw$EmpathyB5 == "Empathy Quintile 2")
svypw.empathyB.3 <- subset(svypw,svypw$EmpathyB5 == "Empathy Quintile 3")
svypw.empathyB.4 <- subset(svypw,svypw$EmpathyB5 == "Empathy Quintile 4")
svypw.empathyB.5 <- subset(svypw,svypw$EmpathyB5 == "Empathy Quintile 5")

mod.empathyB.1 <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.empathyB.1, weights = weight)
coeftest(mod.empathyB.1, vcov = vcovCluster(mod.empathyB.1, factor(svypw.empathyB.1$respid)))
mod.empathyB.2 <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.empathyB.2, weights = weight)
coeftest(mod.empathyB.2, vcov = vcovCluster(mod.empathyB.2, factor(svypw.empathyB.2$respid)))
mod.empathyB.3 <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.empathyB.3, weights = weight)
coeftest(mod.empathyB.3, vcov = vcovCluster(mod.empathyB.3, factor(svypw.empathyB.3$respid)))
mod.empathyB.4 <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.empathyB.4, weights = weight)
coeftest(mod.empathyB.4, vcov = vcovCluster(mod.empathyB.4, factor(svypw.empathyB.4$respid)))
mod.empathyB.5 <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.empathyB.5, weights = weight)
coeftest(mod.empathyB.5, vcov = vcovCluster(mod.empathyB.5, factor(svypw.empathyB.5$respid)))


#Across countries
svypw.cty.austria <- subset(svypw,svypw$cty == "Austria")
svypw.cty.czechrepublic <- subset(svypw,svypw$cty == "Czech Republic")
svypw.cty.denmark <- subset(svypw,svypw$cty == "Denmark")
svypw.cty.france <- subset(svypw,svypw$cty == "France")
svypw.cty.germany <- subset(svypw,svypw$cty == "Germany")
svypw.cty.greece <- subset(svypw,svypw$cty == "Greece")
svypw.cty.hungary <- subset(svypw,svypw$cty == "Hungary")
svypw.cty.italy <- subset(svypw,svypw$cty == "Italy")
svypw.cty.netherlands <- subset(svypw,svypw$cty == "Netherlands")
svypw.cty.norway <- subset(svypw,svypw$cty == "Norway")
svypw.cty.poland <- subset(svypw,svypw$cty == "Poland")
svypw.cty.spain <- subset(svypw,svypw$cty == "Spain")
svypw.cty.sweden <- subset(svypw,svypw$cty == "Sweden")
svypw.cty.switzerland <- subset(svypw,svypw$cty == "Switzerland")
svypw.cty.unitedkingdom <- subset(svypw,svypw$cty == "United Kingdom")

#forced choice:
mod.cty.austriaFC <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.cty.austria, weights = weight)
coeftest(mod.cty.austriaFC, vcov = vcovCluster(mod.cty.austriaFC, factor(svypw.cty.austria$respid)))
mod.cty.czechrepublicFC <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.cty.czechrepublic, weights = weight)
coeftest(mod.cty.czechrepublicFC, vcov = vcovCluster(mod.cty.czechrepublicFC, factor(svypw.cty.czechrepublic$respid)))
mod.cty.denmarkFC <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.cty.denmark, weights = weight)
coeftest(mod.cty.denmarkFC, vcov = vcovCluster(mod.cty.denmarkFC, factor(svypw.cty.denmark$respid)))
mod.cty.franceFC <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.cty.france, weights = weight)
coeftest(mod.cty.franceFC, vcov = vcovCluster(mod.cty.franceFC, factor(svypw.cty.france$respid)))
mod.cty.germanyFC <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.cty.germany, weights = weight)
coeftest(mod.cty.germanyFC, vcov = vcovCluster(mod.cty.germanyFC, factor(svypw.cty.germany$respid)))
mod.cty.greeceFC <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.cty.greece, weights = weight)
coeftest(mod.cty.greeceFC, vcov = vcovCluster(mod.cty.greeceFC, factor(svypw.cty.greece$respid)))
mod.cty.hungaryFC <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.cty.hungary, weights = weight)
coeftest(mod.cty.hungaryFC, vcov = vcovCluster(mod.cty.hungaryFC, factor(svypw.cty.hungary$respid)))
mod.cty.italyFC <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.cty.italy, weights = weight)
coeftest(mod.cty.italyFC, vcov = vcovCluster(mod.cty.italyFC, factor(svypw.cty.italy$respid)))
mod.cty.netherlandsFC <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.cty.netherlands, weights = weight)
coeftest(mod.cty.netherlandsFC, vcov = vcovCluster(mod.cty.netherlandsFC, factor(svypw.cty.netherlands$respid)))
mod.cty.norwayFC <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.cty.norway, weights = weight)
coeftest(mod.cty.norwayFC, vcov = vcovCluster(mod.cty.norwayFC, factor(svypw.cty.norway$respid)))
mod.cty.polandFC <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.cty.poland, weights = weight)
coeftest(mod.cty.polandFC, vcov = vcovCluster(mod.cty.polandFC, factor(svypw.cty.poland$respid)))
mod.cty.spainFC <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.cty.spain, weights = weight)
coeftest(mod.cty.spainFC, vcov = vcovCluster(mod.cty.spainFC, factor(svypw.cty.spain$respid)))
mod.cty.swedenFC <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.cty.sweden, weights = weight)
coeftest(mod.cty.swedenFC, vcov = vcovCluster(mod.cty.swedenFC, factor(svypw.cty.sweden$respid)))
mod.cty.switzerlandFC <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.cty.switzerland, weights = weight)
coeftest(mod.cty.switzerlandFC, vcov = vcovCluster(mod.cty.switzerlandFC, factor(svypw.cty.switzerland$respid)))
mod.cty.unitedkingdomFC <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.cty.unitedkingdom, weights = weight)
coeftest(mod.cty.unitedkingdomFC, vcov = vcovCluster(mod.cty.unitedkingdomFC, factor(svypw.cty.unitedkingdom$respid)))

#binary rating:
mod.cty.austriaBR <- lm(ratebin ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.cty.austria, weights = weight)
coeftest(mod.cty.austriaBR, vcov = vcovCluster(mod.cty.austriaBR, factor(svypw.cty.austria$respid)))
mod.cty.czechrepublicBR <- lm(ratebin ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.cty.czechrepublic, weights = weight)
coeftest(mod.cty.czechrepublicBR, vcov = vcovCluster(mod.cty.czechrepublicBR, factor(svypw.cty.czechrepublic$respid)))
mod.cty.denmarkBR <- lm(ratebin ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.cty.denmark, weights = weight)
coeftest(mod.cty.denmarkBR, vcov = vcovCluster(mod.cty.denmarkBR, factor(svypw.cty.denmark$respid)))
mod.cty.franceBR <- lm(ratebin ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.cty.france, weights = weight)
coeftest(mod.cty.franceBR, vcov = vcovCluster(mod.cty.franceBR, factor(svypw.cty.france$respid)))
mod.cty.germanyBR <- lm(ratebin ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.cty.germany, weights = weight)
coeftest(mod.cty.germanyBR, vcov = vcovCluster(mod.cty.germanyBR, factor(svypw.cty.germany$respid)))
mod.cty.greeceBR <- lm(ratebin ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.cty.greece, weights = weight)
coeftest(mod.cty.greeceBR, vcov = vcovCluster(mod.cty.greeceBR, factor(svypw.cty.greece$respid)))
mod.cty.hungaryBR <- lm(ratebin ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.cty.hungary, weights = weight)
coeftest(mod.cty.hungaryBR, vcov = vcovCluster(mod.cty.hungaryBR, factor(svypw.cty.hungary$respid)))
mod.cty.italyBR <- lm(ratebin ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.cty.italy, weights = weight)
coeftest(mod.cty.italyBR, vcov = vcovCluster(mod.cty.italyBR, factor(svypw.cty.italy$respid)))
mod.cty.netherlandsBR <- lm(ratebin ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.cty.netherlands, weights = weight)
coeftest(mod.cty.netherlandsBR, vcov = vcovCluster(mod.cty.netherlandsBR, factor(svypw.cty.netherlands$respid)))
mod.cty.norwayBR <- lm(ratebin ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.cty.norway, weights = weight)
coeftest(mod.cty.norwayBR, vcov = vcovCluster(mod.cty.norwayBR, factor(svypw.cty.norway$respid)))
mod.cty.polandBR <- lm(ratebin ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.cty.poland, weights = weight)
coeftest(mod.cty.polandBR, vcov = vcovCluster(mod.cty.polandBR, factor(svypw.cty.poland$respid)))
mod.cty.spainBR <- lm(ratebin ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.cty.spain, weights = weight)
coeftest(mod.cty.spainBR, vcov = vcovCluster(mod.cty.spainBR, factor(svypw.cty.spain$respid)))
mod.cty.swedenBR <- lm(ratebin ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.cty.sweden, weights = weight)
coeftest(mod.cty.swedenBR, vcov = vcovCluster(mod.cty.swedenBR, factor(svypw.cty.sweden$respid)))
mod.cty.switzerlandBR <- lm(ratebin ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.cty.switzerland, weights = weight)
coeftest(mod.cty.switzerlandBR, vcov = vcovCluster(mod.cty.switzerlandBR, factor(svypw.cty.switzerland$respid)))
mod.cty.unitedkingdomBR <- lm(ratebin ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.cty.unitedkingdom, weights = weight)
coeftest(mod.cty.unitedkingdomBR, vcov = vcovCluster(mod.cty.unitedkingdomBR, factor(svypw.cty.unitedkingdom$respid)))

#scaled rating:
mod.cty.austriaSR <- lm(ratescaled ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.cty.austria, weights = weight)
coeftest(mod.cty.austriaSR, vcov = vcovCluster(mod.cty.austriaSR, factor(svypw.cty.austria$respid)))
mod.cty.czechrepublicSR <- lm(ratescaled ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.cty.czechrepublic, weights = weight)
coeftest(mod.cty.czechrepublicSR, vcov = vcovCluster(mod.cty.czechrepublicSR, factor(svypw.cty.czechrepublic$respid)))
mod.cty.denmarkSR <- lm(ratescaled ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.cty.denmark, weights = weight)
coeftest(mod.cty.denmarkSR, vcov = vcovCluster(mod.cty.denmarkSR, factor(svypw.cty.denmark$respid)))
mod.cty.franceSR <- lm(ratescaled ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.cty.france, weights = weight)
coeftest(mod.cty.franceSR, vcov = vcovCluster(mod.cty.franceSR, factor(svypw.cty.france$respid)))
mod.cty.germanySR <- lm(ratescaled ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.cty.germany, weights = weight)
coeftest(mod.cty.germanySR, vcov = vcovCluster(mod.cty.germanySR, factor(svypw.cty.germany$respid)))
mod.cty.greeceSR <- lm(ratescaled ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.cty.greece, weights = weight)
coeftest(mod.cty.greeceSR, vcov = vcovCluster(mod.cty.greeceSR, factor(svypw.cty.greece$respid)))
mod.cty.hungarySR <- lm(ratescaled ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.cty.hungary, weights = weight)
coeftest(mod.cty.hungarySR, vcov = vcovCluster(mod.cty.hungarySR, factor(svypw.cty.hungary$respid)))
mod.cty.italySR <- lm(ratescaled ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.cty.italy, weights = weight)
coeftest(mod.cty.italySR, vcov = vcovCluster(mod.cty.italySR, factor(svypw.cty.italy$respid)))
mod.cty.netherlandsSR <- lm(ratescaled ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.cty.netherlands, weights = weight)
coeftest(mod.cty.netherlandsSR, vcov = vcovCluster(mod.cty.netherlandsSR, factor(svypw.cty.netherlands$respid)))
mod.cty.norwaySR <- lm(ratescaled ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.cty.norway, weights = weight)
coeftest(mod.cty.norwaySR, vcov = vcovCluster(mod.cty.norwaySR, factor(svypw.cty.norway$respid)))
mod.cty.polandSR <- lm(ratescaled ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.cty.poland, weights = weight)
coeftest(mod.cty.polandSR, vcov = vcovCluster(mod.cty.polandSR, factor(svypw.cty.poland$respid)))
mod.cty.spainSR <- lm(ratescaled ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.cty.spain, weights = weight)
coeftest(mod.cty.spainSR, vcov = vcovCluster(mod.cty.spainSR, factor(svypw.cty.spain$respid)))
mod.cty.swedenSR <- lm(ratescaled ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.cty.sweden, weights = weight)
coeftest(mod.cty.swedenSR, vcov = vcovCluster(mod.cty.swedenSR, factor(svypw.cty.sweden$respid)))
mod.cty.switzerlandSR <- lm(ratescaled ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.cty.switzerland, weights = weight)
coeftest(mod.cty.switzerlandSR, vcov = vcovCluster(mod.cty.switzerlandSR, factor(svypw.cty.switzerland$respid)))
mod.cty.unitedkingdomSR <- lm(ratescaled ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.cty.unitedkingdom, weights = weight)
coeftest(mod.cty.unitedkingdomSR, vcov = vcovCluster(mod.cty.unitedkingdomSR, factor(svypw.cty.unitedkingdom$respid)))


#Across conjoint tasks (pairs of profiles)
svypw.task.1 <- subset(svypw,svypw$mix == "A" | svypw$mix == "B")
svypw.task.2 <- subset(svypw,svypw$mix == "C" | svypw$mix == "D")
svypw.task.3 <- subset(svypw,svypw$mix == "E" | svypw$mix == "F")
svypw.task.4 <- subset(svypw,svypw$mix == "G" | svypw$mix == "H")
svypw.task.5 <- subset(svypw,svypw$mix == "I" | svypw$mix == "J")

mod.task.1 <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.task.1, weights = weight)
coeftest(mod.task.1, vcov = vcovCluster(mod.task.1, factor(svypw.task.1$respid)))
mod.task.2 <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.task.2, weights = weight)
coeftest(mod.task.2, vcov = vcovCluster(mod.task.2, factor(svypw.task.2$respid)))
mod.task.3 <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.task.3, weights = weight)
coeftest(mod.task.3, vcov = vcovCluster(mod.task.3, factor(svypw.task.3$respid)))
mod.task.4 <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.task.4, weights = weight)
coeftest(mod.task.4, vcov = vcovCluster(mod.task.4, factor(svypw.task.4$respid)))
mod.task.5 <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.task.5, weights = weight)
coeftest(mod.task.5, vcov = vcovCluster(mod.task.5, factor(svypw.task.5$respid)))


#By below and above median survey time
svypw.short <- subset(svypw,svypw$duration <= median(svypw$duration))
svypw.long <- subset(svypw,svypw$duration > median(svypw$duration))

mod.short <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.short, weights = weight)
coeftest(mod.short, vcov = vcovCluster(mod.short, factor(svypw.short$respid)))
mod.long <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.long, weights = weight)
coeftest(mod.long, vcov = vcovCluster(mod.long, factor(svypw.long$respid)))


#By all respondents vs. only native-born respondents
svypw.homeborn <- subset(svypw,svypw$HomeBorn == 1)

basemodweiFC <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw, weights = weight)
coeftest(basemodweiFC, vcov = vcovCluster(basemodweiFC, factor(svypw$respid)))
mod.homeborn <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.homeborn, weights = weight)
coeftest(mod.homeborn, vcov = vcovCluster(mod.homeborn, factor(svypw.homeborn$respid)))



# Alternative ideology coding (by party CHES lrgen score) subset regressions --------

svypwp <- subset(svypw,svypw$lrgen != -888)

unique(cut(svypwp$lrgen,breaks = 5))
svypwp$Ideo5party <- "hold"
svypwp$Ideo5party[svypwp$lrgen > 0.133 & svypwp$lrgen <= 2.11] <- "Far Left"
svypwp$Ideo5party[svypwp$lrgen > 2.11 & svypwp$lrgen <= 4.09] <- "Left"
svypwp$Ideo5party[svypwp$lrgen > 4.09 & svypwp$lrgen <= 6.06] <- "Center"
svypwp$Ideo5party[svypwp$lrgen > 6.06 & svypwp$lrgen <= 8.03] <- "Right"
svypwp$Ideo5party[svypwp$lrgen > 8.03 & svypwp$lrgen <= 10] <- "Far Right"

svypwp.ideo5party.farleft <- subset(svypwp,svypwp$Ideo5party == "Far Left")
svypwp.ideo5party.left <- subset(svypwp,svypwp$Ideo5party == "Left")
svypwp.ideo5party.center <- subset(svypwp,svypwp$Ideo5party == "Center")
svypwp.ideo5party.right <- subset(svypwp,svypwp$Ideo5party == "Right")
svypwp.ideo5party.farright <- subset(svypwp,svypwp$Ideo5party == "Far Right")

mod.ideo5party.farleft <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypwp.ideo5party.farleft, weights = weight)
coeftest(mod.ideo5party.farleft, vcov = vcovCluster(mod.ideo5party.farleft, factor(svypwp.ideo5party.farleft$respid)))
mod.ideo5party.left <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypwp.ideo5party.left, weights = weight)
coeftest(mod.ideo5party.left, vcov = vcovCluster(mod.ideo5party.left, factor(svypwp.ideo5party.left$respid)))
mod.ideo5party.center <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypwp.ideo5party.center, weights = weight)
coeftest(mod.ideo5party.center, vcov = vcovCluster(mod.ideo5party.center, factor(svypwp.ideo5party.center$respid)))
mod.ideo5party.right <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypwp.ideo5party.right, weights = weight)
coeftest(mod.ideo5party.right, vcov = vcovCluster(mod.ideo5party.right, factor(svypwp.ideo5party.right$respid)))
mod.ideo5party.farright <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypwp.ideo5party.farright, weights = weight)
coeftest(mod.ideo5party.farright, vcov = vcovCluster(mod.ideo5party.farright, factor(svypwp.ideo5party.farright$respid)))


# Interaction subset regressions for Supplementary Materials --------------

#by asylum testimony consistency levels
svypw.consistency.1 <- subset(svypw,svypw$cconsist == 1) #No inconsistencies
svypw.consistency.2 <- subset(svypw,svypw$cconsist == 2) #Minor inconsistencies
svypw.consistency.3 <- subset(svypw,svypw$cconsist == 3) #Major inconsistencies

mod.consistency.1FC <- lm(pref ~ cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.consistency.1, weights = weight)
coeftest(mod.consistency.1FC, vcov = vcovCluster(mod.consistency.1FC, factor(svypw.consistency.1$respid)))
mod.consistency.2FC <- lm(pref ~ cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.consistency.2, weights = weight)
coeftest(mod.consistency.2FC, vcov = vcovCluster(mod.consistency.2FC, factor(svypw.consistency.2$respid)))
mod.consistency.3FC <- lm(pref ~ cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.consistency.3, weights = weight)
coeftest(mod.consistency.3FC, vcov = vcovCluster(mod.consistency.3FC, factor(svypw.consistency.3$respid)))

mod.consistency.1BR <- lm(ratebin ~ cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.consistency.1, weights = weight)
coeftest(mod.consistency.1BR, vcov = vcovCluster(mod.consistency.1BR, factor(svypw.consistency.1$respid)))
mod.consistency.2BR <- lm(ratebin ~ cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.consistency.2, weights = weight)
coeftest(mod.consistency.2BR, vcov = vcovCluster(mod.consistency.2BR, factor(svypw.consistency.2$respid)))
mod.consistency.3BR <- lm(ratebin ~ cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.consistency.3, weights = weight)
coeftest(mod.consistency.3BR, vcov = vcovCluster(mod.consistency.3BR, factor(svypw.consistency.3$respid)))

mod.consistency.1SR <- lm(ratescaled ~ cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.consistency.1, weights = weight)
coeftest(mod.consistency.1SR, vcov = vcovCluster(mod.consistency.1SR, factor(svypw.consistency.1$respid)))
mod.consistency.2SR <- lm(ratescaled ~ cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.consistency.2, weights = weight)
coeftest(mod.consistency.2SR, vcov = vcovCluster(mod.consistency.2SR, factor(svypw.consistency.2$respid)))
mod.consistency.3SR <- lm(ratescaled ~ cgender + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.consistency.3, weights = weight)
coeftest(mod.consistency.3SR, vcov = vcovCluster(mod.consistency.3SR, factor(svypw.consistency.3$respid)))


#by asylum-seeker's gender
svypw.gender.1 <- subset(svypw,svypw$cgender == 1) #Female
svypw.gender.2 <- subset(svypw,svypw$cgender == 2) #Male

mod.gender.1FC <- lm(pref ~ cconsist + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.gender.1, weights = weight)
coeftest(mod.gender.1FC, vcov = vcovCluster(mod.gender.1FC, factor(svypw.gender.1$respid)))
mod.gender.2FC <- lm(pref ~ cconsist + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.gender.2, weights = weight)
coeftest(mod.gender.2FC, vcov = vcovCluster(mod.gender.2FC, factor(svypw.gender.2$respid)))

mod.gender.1BR <- lm(ratebin ~ cconsist + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.gender.1, weights = weight)
coeftest(mod.gender.1BR, vcov = vcovCluster(mod.gender.1BR, factor(svypw.gender.1$respid)))
mod.gender.2BR <- lm(ratebin ~ cconsist + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.gender.2, weights = weight)
coeftest(mod.gender.2BR, vcov = vcovCluster(mod.gender.2BR, factor(svypw.gender.2$respid)))

mod.gender.1SR <- lm(ratescaled ~ cconsist + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.gender.1, weights = weight)
coeftest(mod.gender.1SR, vcov = vcovCluster(mod.gender.1SR, factor(svypw.gender.1$respid)))
mod.gender.2SR <- lm(ratescaled ~ cconsist + corigin + cage + cjob + cvulner + creason + creligion + clang, data = svypw.gender.2, weights = weight)
coeftest(mod.gender.2SR, vcov = vcovCluster(mod.gender.2SR, factor(svypw.gender.2$respid)))


#by asylum-seeker's country of origin
svypw.origin.1 <- subset(svypw,svypw$corigin == 1) #Syria
svypw.origin.2 <- subset(svypw,svypw$corigin == 2) #Afghanistan
svypw.origin.3 <- subset(svypw,svypw$corigin == 3) #Kosovo
svypw.origin.4 <- subset(svypw,svypw$corigin == 4) #Eritrea
svypw.origin.5 <- subset(svypw,svypw$corigin == 5) #Pakistan
svypw.origin.6 <- subset(svypw,svypw$corigin == 6) #Ukraine
svypw.origin.7 <- subset(svypw,svypw$corigin == 7) #Iraq

mod.origin.1FC <- lm(pref ~ cconsist + cgender + cage + cjob + cvulner + creason + creligion + clang, data = svypw.origin.1, weights = weight)
coeftest(mod.origin.1FC, vcov = vcovCluster(mod.origin.1FC, factor(svypw.origin.1$respid)))
mod.origin.2FC <- lm(pref ~ cconsist + cgender + cage + cjob + cvulner + creason + creligion + clang, data = svypw.origin.2, weights = weight)
coeftest(mod.origin.2FC, vcov = vcovCluster(mod.origin.2FC, factor(svypw.origin.2$respid)))
mod.origin.3FC <- lm(pref ~ cconsist + cgender + cage + cjob + cvulner + creason + creligion + clang, data = svypw.origin.3, weights = weight)
coeftest(mod.origin.3FC, vcov = vcovCluster(mod.origin.3FC, factor(svypw.origin.3$respid)))
mod.origin.4FC <- lm(pref ~ cconsist + cgender + cage + cjob + cvulner + creason + creligion + clang, data = svypw.origin.4, weights = weight)
coeftest(mod.origin.4FC, vcov = vcovCluster(mod.origin.4FC, factor(svypw.origin.4$respid)))
mod.origin.5FC <- lm(pref ~ cconsist + cgender + cage + cjob + cvulner + creason + creligion + clang, data = svypw.origin.5, weights = weight)
coeftest(mod.origin.5FC, vcov = vcovCluster(mod.origin.5FC, factor(svypw.origin.5$respid)))
mod.origin.6FC <- lm(pref ~ cconsist + cgender + cage + cjob + cvulner + creason + creligion + clang, data = svypw.origin.6, weights = weight)
coeftest(mod.origin.6FC, vcov = vcovCluster(mod.origin.6FC, factor(svypw.origin.6$respid)))
mod.origin.7FC <- lm(pref ~ cconsist + cgender + cage + cjob + cvulner + creason + creligion + clang, data = svypw.origin.7, weights = weight)
coeftest(mod.origin.7FC, vcov = vcovCluster(mod.origin.7FC, factor(svypw.origin.7$respid)))

mod.origin.1BR <- lm(ratebin ~ cconsist + cgender + cage + cjob + cvulner + creason + creligion + clang, data = svypw.origin.1, weights = weight)
coeftest(mod.origin.1BR, vcov = vcovCluster(mod.origin.1BR, factor(svypw.origin.1$respid)))
mod.origin.2BR <- lm(ratebin ~ cconsist + cgender + cage + cjob + cvulner + creason + creligion + clang, data = svypw.origin.2, weights = weight)
coeftest(mod.origin.2BR, vcov = vcovCluster(mod.origin.2BR, factor(svypw.origin.2$respid)))
mod.origin.3BR <- lm(ratebin ~ cconsist + cgender + cage + cjob + cvulner + creason + creligion + clang, data = svypw.origin.3, weights = weight)
coeftest(mod.origin.3BR, vcov = vcovCluster(mod.origin.3BR, factor(svypw.origin.3$respid)))
mod.origin.4BR <- lm(ratebin ~ cconsist + cgender + cage + cjob + cvulner + creason + creligion + clang, data = svypw.origin.4, weights = weight)
coeftest(mod.origin.4BR, vcov = vcovCluster(mod.origin.4BR, factor(svypw.origin.4$respid)))
mod.origin.5BR <- lm(ratebin ~ cconsist + cgender + cage + cjob + cvulner + creason + creligion + clang, data = svypw.origin.5, weights = weight)
coeftest(mod.origin.5BR, vcov = vcovCluster(mod.origin.5BR, factor(svypw.origin.5$respid)))
mod.origin.6BR <- lm(ratebin ~ cconsist + cgender + cage + cjob + cvulner + creason + creligion + clang, data = svypw.origin.6, weights = weight)
coeftest(mod.origin.6BR, vcov = vcovCluster(mod.origin.6BR, factor(svypw.origin.6$respid)))
mod.origin.7BR <- lm(ratebin ~ cconsist + cgender + cage + cjob + cvulner + creason + creligion + clang, data = svypw.origin.7, weights = weight)
coeftest(mod.origin.7BR, vcov = vcovCluster(mod.origin.7BR, factor(svypw.origin.7$respid)))

mod.origin.1SR <- lm(ratescaled ~ cconsist + cgender + cage + cjob + cvulner + creason + creligion + clang, data = svypw.origin.1, weights = weight)
coeftest(mod.origin.1SR, vcov = vcovCluster(mod.origin.1SR, factor(svypw.origin.1$respid)))
mod.origin.2SR <- lm(ratescaled ~ cconsist + cgender + cage + cjob + cvulner + creason + creligion + clang, data = svypw.origin.2, weights = weight)
coeftest(mod.origin.2SR, vcov = vcovCluster(mod.origin.2SR, factor(svypw.origin.2$respid)))
mod.origin.3SR <- lm(ratescaled ~ cconsist + cgender + cage + cjob + cvulner + creason + creligion + clang, data = svypw.origin.3, weights = weight)
coeftest(mod.origin.3SR, vcov = vcovCluster(mod.origin.3SR, factor(svypw.origin.3$respid)))
mod.origin.4SR <- lm(ratescaled ~ cconsist + cgender + cage + cjob + cvulner + creason + creligion + clang, data = svypw.origin.4, weights = weight)
coeftest(mod.origin.4SR, vcov = vcovCluster(mod.origin.4SR, factor(svypw.origin.4$respid)))
mod.origin.5SR <- lm(ratescaled ~ cconsist + cgender + cage + cjob + cvulner + creason + creligion + clang, data = svypw.origin.5, weights = weight)
coeftest(mod.origin.5SR, vcov = vcovCluster(mod.origin.5SR, factor(svypw.origin.5$respid)))
mod.origin.6SR <- lm(ratescaled ~ cconsist + cgender + cage + cjob + cvulner + creason + creligion + clang, data = svypw.origin.6, weights = weight)
coeftest(mod.origin.6SR, vcov = vcovCluster(mod.origin.6SR, factor(svypw.origin.6$respid)))
mod.origin.7SR <- lm(ratescaled ~ cconsist + cgender + cage + cjob + cvulner + creason + creligion + clang, data = svypw.origin.7, weights = weight)
coeftest(mod.origin.7SR, vcov = vcovCluster(mod.origin.7SR, factor(svypw.origin.7$respid)))


#by asylum-seeker's age
svypw.age.1 <- subset(svypw,svypw$cage == 1) #21 years
svypw.age.2 <- subset(svypw,svypw$cage == 2) #38 years
svypw.age.3 <- subset(svypw,svypw$cage == 3) #62 years

mod.age.1FC <- lm(pref ~ cconsist + cgender + corigin + cjob + cvulner + creason + creligion + clang, data = svypw.age.1, weights = weight)
coeftest(mod.age.1FC, vcov = vcovCluster(mod.age.1FC, factor(svypw.age.1$respid)))
mod.age.2FC <- lm(pref ~ cconsist + cgender + corigin + cjob + cvulner + creason + creligion + clang, data = svypw.age.2, weights = weight)
coeftest(mod.age.2FC, vcov = vcovCluster(mod.age.2FC, factor(svypw.age.2$respid)))
mod.age.3FC <- lm(pref ~ cconsist + cgender + corigin + cjob + cvulner + creason + creligion + clang, data = svypw.age.3, weights = weight)
coeftest(mod.age.3FC, vcov = vcovCluster(mod.age.3FC, factor(svypw.age.3$respid)))

mod.age.1BR <- lm(ratebin ~ cconsist + cgender + corigin + cjob + cvulner + creason + creligion + clang, data = svypw.age.1, weights = weight)
coeftest(mod.age.1BR, vcov = vcovCluster(mod.age.1BR, factor(svypw.age.1$respid)))
mod.age.2BR <- lm(ratebin ~ cconsist + cgender + corigin + cjob + cvulner + creason + creligion + clang, data = svypw.age.2, weights = weight)
coeftest(mod.age.2BR, vcov = vcovCluster(mod.age.2BR, factor(svypw.age.2$respid)))
mod.age.3BR <- lm(ratebin ~ cconsist + cgender + corigin + cjob + cvulner + creason + creligion + clang, data = svypw.age.3, weights = weight)
coeftest(mod.age.3BR, vcov = vcovCluster(mod.age.3BR, factor(svypw.age.3$respid)))

mod.age.1SR <- lm(ratescaled ~ cconsist + cgender + corigin + cjob + cvulner + creason + creligion + clang, data = svypw.age.1, weights = weight)
coeftest(mod.age.1SR, vcov = vcovCluster(mod.age.1SR, factor(svypw.age.1$respid)))
mod.age.2SR <- lm(ratescaled ~ cconsist + cgender + corigin + cjob + cvulner + creason + creligion + clang, data = svypw.age.2, weights = weight)
coeftest(mod.age.2SR, vcov = vcovCluster(mod.age.2SR, factor(svypw.age.2$respid)))
mod.age.3SR <- lm(ratescaled ~ cconsist + cgender + corigin + cjob + cvulner + creason + creligion + clang, data = svypw.age.3, weights = weight)
coeftest(mod.age.3SR, vcov = vcovCluster(mod.age.3SR, factor(svypw.age.3$respid)))


#by asylum-seeker's previous occupation
svypw.job.1 <- subset(svypw,svypw$cjob == 1) #Unemployed
svypw.job.2 <- subset(svypw,svypw$cjob == 2) #Cleaner
svypw.job.3 <- subset(svypw,svypw$cjob == 3) #Farmer
svypw.job.4 <- subset(svypw,svypw$cjob == 4) #Accountant
svypw.job.5 <- subset(svypw,svypw$cjob == 5) #Teacher
svypw.job.6 <- subset(svypw,svypw$cjob == 6) #Doctor

mod.job.1FC <- lm(pref ~ cconsist + cgender + corigin + cage + cvulner + creason + creligion + clang, data = svypw.job.1, weights = weight)
coeftest(mod.job.1FC, vcov = vcovCluster(mod.job.1FC, factor(svypw.job.1$respid)))
mod.job.2FC <- lm(pref ~ cconsist + cgender + corigin + cage + cvulner + creason + creligion + clang, data = svypw.job.2, weights = weight)
coeftest(mod.job.2FC, vcov = vcovCluster(mod.job.2FC, factor(svypw.job.2$respid)))
mod.job.3FC <- lm(pref ~ cconsist + cgender + corigin + cage + cvulner + creason + creligion + clang, data = svypw.job.3, weights = weight)
coeftest(mod.job.3FC, vcov = vcovCluster(mod.job.3FC, factor(svypw.job.3$respid)))
mod.job.4FC <- lm(pref ~ cconsist + cgender + corigin + cage + cvulner + creason + creligion + clang, data = svypw.job.4, weights = weight)
coeftest(mod.job.4FC, vcov = vcovCluster(mod.job.4FC, factor(svypw.job.4$respid)))
mod.job.5FC <- lm(pref ~ cconsist + cgender + corigin + cage + cvulner + creason + creligion + clang, data = svypw.job.5, weights = weight)
coeftest(mod.job.5FC, vcov = vcovCluster(mod.job.5FC, factor(svypw.job.5$respid)))
mod.job.6FC <- lm(pref ~ cconsist + cgender + corigin + cage + cvulner + creason + creligion + clang, data = svypw.job.6, weights = weight)
coeftest(mod.job.6FC, vcov = vcovCluster(mod.job.6FC, factor(svypw.job.6$respid)))

mod.job.1BR <- lm(ratebin ~ cconsist + cgender + corigin + cage + cvulner + creason + creligion + clang, data = svypw.job.1, weights = weight)
coeftest(mod.job.1BR, vcov = vcovCluster(mod.job.1BR, factor(svypw.job.1$respid)))
mod.job.2BR <- lm(ratebin ~ cconsist + cgender + corigin + cage + cvulner + creason + creligion + clang, data = svypw.job.2, weights = weight)
coeftest(mod.job.2BR, vcov = vcovCluster(mod.job.2BR, factor(svypw.job.2$respid)))
mod.job.3BR <- lm(ratebin ~ cconsist + cgender + corigin + cage + cvulner + creason + creligion + clang, data = svypw.job.3, weights = weight)
coeftest(mod.job.3BR, vcov = vcovCluster(mod.job.3BR, factor(svypw.job.3$respid)))
mod.job.4BR <- lm(ratebin ~ cconsist + cgender + corigin + cage + cvulner + creason + creligion + clang, data = svypw.job.4, weights = weight)
coeftest(mod.job.4BR, vcov = vcovCluster(mod.job.4BR, factor(svypw.job.4$respid)))
mod.job.5BR <- lm(ratebin ~ cconsist + cgender + corigin + cage + cvulner + creason + creligion + clang, data = svypw.job.5, weights = weight)
coeftest(mod.job.5BR, vcov = vcovCluster(mod.job.5BR, factor(svypw.job.5$respid)))
mod.job.6BR <- lm(ratebin ~ cconsist + cgender + corigin + cage + cvulner + creason + creligion + clang, data = svypw.job.6, weights = weight)
coeftest(mod.job.6BR, vcov = vcovCluster(mod.job.6BR, factor(svypw.job.6$respid)))

mod.job.1SR <- lm(ratescaled ~ cconsist + cgender + corigin + cage + cvulner + creason + creligion + clang, data = svypw.job.1, weights = weight)
coeftest(mod.job.1SR, vcov = vcovCluster(mod.job.1SR, factor(svypw.job.1$respid)))
mod.job.2SR <- lm(ratescaled ~ cconsist + cgender + corigin + cage + cvulner + creason + creligion + clang, data = svypw.job.2, weights = weight)
coeftest(mod.job.2SR, vcov = vcovCluster(mod.job.2SR, factor(svypw.job.2$respid)))
mod.job.3SR <- lm(ratescaled ~ cconsist + cgender + corigin + cage + cvulner + creason + creligion + clang, data = svypw.job.3, weights = weight)
coeftest(mod.job.3SR, vcov = vcovCluster(mod.job.3SR, factor(svypw.job.3$respid)))
mod.job.4SR <- lm(ratescaled ~ cconsist + cgender + corigin + cage + cvulner + creason + creligion + clang, data = svypw.job.4, weights = weight)
coeftest(mod.job.4SR, vcov = vcovCluster(mod.job.4SR, factor(svypw.job.4$respid)))
mod.job.5SR <- lm(ratescaled ~ cconsist + cgender + corigin + cage + cvulner + creason + creligion + clang, data = svypw.job.5, weights = weight)
coeftest(mod.job.5SR, vcov = vcovCluster(mod.job.5SR, factor(svypw.job.5$respid)))
mod.job.6SR <- lm(ratescaled ~ cconsist + cgender + corigin + cage + cvulner + creason + creligion + clang, data = svypw.job.6, weights = weight)
coeftest(mod.job.6SR, vcov = vcovCluster(mod.job.6SR, factor(svypw.job.6$respid)))


#by asylum seeker's special vulnerabilities
svypw.vulner.1 <- subset(svypw,svypw$cvulner == 1) #None
svypw.vulner.2 <- subset(svypw,svypw$cvulner == 2) #PTSD
svypw.vulner.3 <- subset(svypw,svypw$cvulner == 3) #Victim of torture
svypw.vulner.4 <- subset(svypw,svypw$cvulner == 4) #No surviving family
svypw.vulner.5 <- subset(svypw,svypw$cvulner == 5) #Handicapped

mod.vulner.1FC <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + creason + creligion + clang, data = svypw.vulner.1, weights = weight)
coeftest(mod.vulner.1FC, vcov = vcovCluster(mod.vulner.1FC, factor(svypw.vulner.1$respid)))
mod.vulner.2FC <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + creason + creligion + clang, data = svypw.vulner.2, weights = weight)
coeftest(mod.vulner.2FC, vcov = vcovCluster(mod.vulner.2FC, factor(svypw.vulner.2$respid)))
mod.vulner.3FC <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + creason + creligion + clang, data = svypw.vulner.3, weights = weight)
coeftest(mod.vulner.3FC, vcov = vcovCluster(mod.vulner.3FC, factor(svypw.vulner.3$respid)))
mod.vulner.4FC <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + creason + creligion + clang, data = svypw.vulner.4, weights = weight)
coeftest(mod.vulner.4FC, vcov = vcovCluster(mod.vulner.4FC, factor(svypw.vulner.4$respid)))
mod.vulner.5FC <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + creason + creligion + clang, data = svypw.vulner.5, weights = weight)
coeftest(mod.vulner.5FC, vcov = vcovCluster(mod.vulner.5FC, factor(svypw.vulner.5$respid)))

mod.vulner.1BR <- lm(ratebin ~ cconsist + cgender + corigin + cage + cjob + creason + creligion + clang, data = svypw.vulner.1, weights = weight)
coeftest(mod.vulner.1BR, vcov = vcovCluster(mod.vulner.1BR, factor(svypw.vulner.1$respid)))
mod.vulner.2BR <- lm(ratebin ~ cconsist + cgender + corigin + cage + cjob + creason + creligion + clang, data = svypw.vulner.2, weights = weight)
coeftest(mod.vulner.2BR, vcov = vcovCluster(mod.vulner.2BR, factor(svypw.vulner.2$respid)))
mod.vulner.3BR <- lm(ratebin ~ cconsist + cgender + corigin + cage + cjob + creason + creligion + clang, data = svypw.vulner.3, weights = weight)
coeftest(mod.vulner.3BR, vcov = vcovCluster(mod.vulner.3BR, factor(svypw.vulner.3$respid)))
mod.vulner.4BR <- lm(ratebin ~ cconsist + cgender + corigin + cage + cjob + creason + creligion + clang, data = svypw.vulner.4, weights = weight)
coeftest(mod.vulner.4BR, vcov = vcovCluster(mod.vulner.4BR, factor(svypw.vulner.4$respid)))
mod.vulner.5BR <- lm(ratebin ~ cconsist + cgender + corigin + cage + cjob + creason + creligion + clang, data = svypw.vulner.5, weights = weight)
coeftest(mod.vulner.5BR, vcov = vcovCluster(mod.vulner.5BR, factor(svypw.vulner.5$respid)))

mod.vulner.1SR <- lm(ratescaled ~ cconsist + cgender + corigin + cage + cjob + creason + creligion + clang, data = svypw.vulner.1, weights = weight)
coeftest(mod.vulner.1SR, vcov = vcovCluster(mod.vulner.1SR, factor(svypw.vulner.1$respid)))
mod.vulner.2SR <- lm(ratescaled ~ cconsist + cgender + corigin + cage + cjob + creason + creligion + clang, data = svypw.vulner.2, weights = weight)
coeftest(mod.vulner.2SR, vcov = vcovCluster(mod.vulner.2SR, factor(svypw.vulner.2$respid)))
mod.vulner.3SR <- lm(ratescaled ~ cconsist + cgender + corigin + cage + cjob + creason + creligion + clang, data = svypw.vulner.3, weights = weight)
coeftest(mod.vulner.3SR, vcov = vcovCluster(mod.vulner.3SR, factor(svypw.vulner.3$respid)))
mod.vulner.4SR <- lm(ratescaled ~ cconsist + cgender + corigin + cage + cjob + creason + creligion + clang, data = svypw.vulner.4, weights = weight)
coeftest(mod.vulner.4SR, vcov = vcovCluster(mod.vulner.4SR, factor(svypw.vulner.4$respid)))
mod.vulner.5SR <- lm(ratescaled ~ cconsist + cgender + corigin + cage + cjob + creason + creligion + clang, data = svypw.vulner.5, weights = weight)
coeftest(mod.vulner.5SR, vcov = vcovCluster(mod.vulner.5SR, factor(svypw.vulner.5$respid)))


#by asylum-seeker's reason for migrating
svypw.polpers <- subset(svypw,svypw$creason == 1) #Political persecution
svypw.relpers <- subset(svypw,svypw$creason == 2) #Religious persecution
svypw.ethpers <- subset(svypw,svypw$creason == 3) #Ethnic persecution
svypw.pers <- subset(svypw,svypw$creason == 1 | svypw$creason == 2 | svypw$creason == 3) #Persecution (pooling political, religious, ethnic)
svypw.econopp <- subset(svypw,svypw$creason == 4) #Economic opportunities

mod.persFC <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creligion + clang, data = svypw.pers, weights = weight)
coeftest(mod.persFC, vcov = vcovCluster(mod.persFC, factor(svypw.pers$respid)))
mod.econoppFC <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creligion + clang, data = svypw.econopp, weights = weight)
coeftest(mod.econoppFC, vcov = vcovCluster(mod.econoppFC, factor(svypw.econopp$respid)))

mod.persBR <- lm(ratebin ~ cconsist + cgender + corigin + cage + cjob + cvulner + creligion + clang, data = svypw.pers, weights = weight)
coeftest(mod.persBR, vcov = vcovCluster(mod.persBR, factor(svypw.pers$respid)))
mod.econoppBR <- lm(ratebin ~ cconsist + cgender + corigin + cage + cjob + cvulner + creligion + clang, data = svypw.econopp, weights = weight)
coeftest(mod.econoppBR, vcov = vcovCluster(mod.econoppBR, factor(svypw.econopp$respid)))

mod.persSR <- lm(ratescaled ~ cconsist + cgender + corigin + cage + cjob + cvulner + creligion + clang, data = svypw.pers, weights = weight)
coeftest(mod.persSR, vcov = vcovCluster(mod.persSR, factor(svypw.pers$respid)))
mod.econoppSR <- lm(ratescaled ~ cconsist + cgender + corigin + cage + cjob + cvulner + creligion + clang, data = svypw.econopp, weights = weight)
coeftest(mod.econoppSR, vcov = vcovCluster(mod.econoppSR, factor(svypw.econopp$respid)))


#by asylum-seeker's religion
svypw.religion.1 <- subset(svypw,svypw$creligion == 1) #Christian
svypw.religion.2 <- subset(svypw,svypw$creligion == 2) #Agnostic
svypw.religion.3 <- subset(svypw,svypw$creligion == 3) #Muslim

mod.religion.1FC <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + clang, data = svypw.religion.1, weights = weight)
coeftest(mod.religion.1FC, vcov = vcovCluster(mod.religion.1FC, factor(svypw.religion.1$respid)))
mod.religion.2FC <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + clang, data = svypw.religion.2, weights = weight)
coeftest(mod.religion.2FC, vcov = vcovCluster(mod.religion.2FC, factor(svypw.religion.2$respid)))
mod.religion.3FC <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + clang, data = svypw.religion.3, weights = weight)
coeftest(mod.religion.3FC, vcov = vcovCluster(mod.religion.3FC, factor(svypw.religion.3$respid)))

mod.religion.1BR <- lm(ratebin ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + clang, data = svypw.religion.1, weights = weight)
coeftest(mod.religion.1BR, vcov = vcovCluster(mod.religion.1BR, factor(svypw.religion.1$respid)))
mod.religion.2BR <- lm(ratebin ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + clang, data = svypw.religion.2, weights = weight)
coeftest(mod.religion.2BR, vcov = vcovCluster(mod.religion.2BR, factor(svypw.religion.2$respid)))
mod.religion.3BR <- lm(ratebin ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + clang, data = svypw.religion.3, weights = weight)
coeftest(mod.religion.3BR, vcov = vcovCluster(mod.religion.3BR, factor(svypw.religion.3$respid)))

mod.religion.1SR <- lm(ratescaled ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + clang, data = svypw.religion.1, weights = weight)
coeftest(mod.religion.1SR, vcov = vcovCluster(mod.religion.1SR, factor(svypw.religion.1$respid)))
mod.religion.2SR <- lm(ratescaled ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + clang, data = svypw.religion.2, weights = weight)
coeftest(mod.religion.2SR, vcov = vcovCluster(mod.religion.2SR, factor(svypw.religion.2$respid)))
mod.religion.3SR <- lm(ratescaled ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + clang, data = svypw.religion.3, weights = weight)
coeftest(mod.religion.3SR, vcov = vcovCluster(mod.religion.3SR, factor(svypw.religion.3$respid)))


#by asylum-seeker's language skills
svypw.langskills.1 <- subset(svypw,svypw$clang == 1) #Fluent
svypw.langskills.2 <- subset(svypw,svypw$clang == 2) #Broken
svypw.langskills.3 <- subset(svypw,svypw$clang == 3) #None

mod.langskills.1FC <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion, data = svypw.langskills.1, weights = weight)
coeftest(mod.langskills.1FC, vcov = vcovCluster(mod.langskills.1FC, factor(svypw.langskills.1$respid)))
mod.langskills.2FC <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion, data = svypw.langskills.2, weights = weight)
coeftest(mod.langskills.2FC, vcov = vcovCluster(mod.langskills.2FC, factor(svypw.langskills.2$respid)))
mod.langskills.3FC <- lm(pref ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion, data = svypw.langskills.3, weights = weight)
coeftest(mod.langskills.3FC, vcov = vcovCluster(mod.langskills.3FC, factor(svypw.langskills.3$respid)))

mod.langskills.1BR <- lm(ratebin ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion, data = svypw.langskills.1, weights = weight)
coeftest(mod.langskills.1BR, vcov = vcovCluster(mod.langskills.1BR, factor(svypw.langskills.1$respid)))
mod.langskills.2BR <- lm(ratebin ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion, data = svypw.langskills.2, weights = weight)
coeftest(mod.langskills.2BR, vcov = vcovCluster(mod.langskills.2BR, factor(svypw.langskills.2$respid)))
mod.langskills.3BR <- lm(ratebin ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion, data = svypw.langskills.3, weights = weight)
coeftest(mod.langskills.3BR, vcov = vcovCluster(mod.langskills.3BR, factor(svypw.langskills.3$respid)))

mod.langskills.1SR <- lm(ratescaled ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion, data = svypw.langskills.1, weights = weight)
coeftest(mod.langskills.1SR, vcov = vcovCluster(mod.langskills.1SR, factor(svypw.langskills.1$respid)))
mod.langskills.2SR <- lm(ratescaled ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion, data = svypw.langskills.2, weights = weight)
coeftest(mod.langskills.2SR, vcov = vcovCluster(mod.langskills.2SR, factor(svypw.langskills.2$respid)))
mod.langskills.3SR <- lm(ratescaled ~ cconsist + cgender + corigin + cage + cjob + cvulner + creason + creligion, data = svypw.langskills.3, weights = weight)
coeftest(mod.langskills.3SR, vcov = vcovCluster(mod.langskills.3SR, factor(svypw.langskills.3$respid)))

